// pages/index/store_xq.js
Page({

  data: {  storexq:{},banner:[],array:[],biggoods:{},near_id:'',index2:0,goods_id:'',statu:'',mi:'',id:''

  },
  onPullDownRefresh(){
    this.getstorexq(this.data.near_id)
    this.getgoodslist(this.data.near_id)
   
  },
  onShow(){
    console.log(this.data.id);
    
    let uid=wx.getStorageSync('uid')?wx.getStorageSync('uid'):''
    if(uid==''){
      wx.navigateTo({
        url: '/pages/mine/loginuser/loginuser',
      })
    }
    if(this.data.id!=''&&uid!=''){
      this.getstorexq(this.data.id)
    this.getgoodslist(this.data.id)
    }
  
    
   
  },
  onLoad: function (options) {
    
    console.log(options);
    if(!options.scene){
      console.log(1111);
      
      this.setData({
        statu:options.statu,
        mi:parseInt(options.mi),
        
   })
   console.log(options,this.data.statu);
  
   
   this.getstorexq(options.near_id)
   this.getgoodslist(options.near_id)
   this.setData({near_id:options.near_id})}
    
   if (options.scene){
 
    const scene = decodeURIComponent(options.scene)
    console.log(scene)  // 22&shopname

    var id = scene.substring(4)
    
    this.setData({id,near_id:id,statu:'index'})
  }  
   

  },
  getstorexq(near_id){
    wx.request({
      url: 'https://zujieba.com/api/store/index.html',
      data:{pid:near_id},
      success:(res)=>{
        console.log(res);
      let storexq=res.data.data
      let banner=res.data.data.banner
      this.setData({
        storexq,
        banner

      })
      wx.stopPullDownRefresh()
      }
    })
  },
  //获取设备列表
   getgoodslist(near_id){
      wx.request({
        url: 'https://zujieba.com/Api/store/goods.html',
        data:{pid:near_id},
        method:'POST',
        success:(res)=>{
          console.log(res);
          let biggoods=res.data.data
          let goods_id=res.data.data[0].id
   
        this.setData({
          goods_id,
          biggoods
        })
        wx.stopPullDownRefresh()
          
        }
      })
   },
   //拿到设备的id
    navback(e){
      console.log(e);
      
      let index2=e.currentTarget.dataset.index
      this.setData({index2,goods_id:e.currentTarget.dataset.goods_id })
    
    },
  //返回打印
  navbackto(){
    
    
    if(this.data.statu=='index'||this.data.statu=='index1'){
       wx.navigateTo({
         url: '/pages/hebin/hebin?near_id='+this.data.near_id+"&goods_id="+this.data.goods_id,
       })
    }else{
      var pages = getCurrentPages()   
      　　 var currentPage = pages[pages.length - 1] 
      　　var prevPage = pages[pages.length - 3]    
      　　
      　　prevPage.setData({
      　　　　goods_id:this.data.goods_id ,
             near_id:this.data.near_id      })
            wx.navigateBack({
              
              delta:2,
              complete: (res) => {},
            })

    }
      
   
  },
  
  
})